package cn.liu.jetpack_demo.pages


import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.Button
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController
import cn.liu.jetpack_demo.BuildConfig
import cn.liu.jetpack_demo.routes.PASSPORT_ROUTE
import cn.liu.jetpack_demo.routes.Screen

@Composable
fun HomePage(navController: NavController) {
    Box(
        modifier = Modifier
            .fillMaxSize()
            .background(Color.Magenta),
        contentAlignment = Alignment.Center
    ) {
        Column(
            modifier = Modifier.fillMaxSize(),
            horizontalAlignment = Alignment.CenterHorizontally,
            verticalArrangement = Arrangement.Center
        ) {
            Text(
                modifier = Modifier.clickable {
//                navController.navigate(route = "detail_screen/1")
//                navController.navigate(route = Screen.Detail.passId(4))
                    navController.navigate(
                        route = Screen.Detail.passNameAndId(
                            id = 1,
                            name = "liuc"
                        )
                    )
                },
                text = "Home",
                color = Color.White,
                fontWeight = FontWeight.Bold,
                fontSize = MaterialTheme.typography.headlineLarge.fontSize
            )
            Button(onClick = {
                navController.navigate(route = Screen.UserList.route)
            }) {
                Text("User List Page")
            }

            Button(onClick = {
                navController.navigate(route = Screen.StickyHeader.route)
            }) {
                Text("Sticky Header List")
            }

            Button(onClick = {
                navController.navigate(PASSPORT_ROUTE)
            }) {
                Text("Go Login")
            }
            Text(text = "${BuildConfig.API_KEY}")
        }
    }
}

@Composable
@Preview
fun HomePagePreview(showBackground: Boolean = true) {
    HomePage(navController = rememberNavController())
}
